import React, { useEffect, useState } from 'react'
import PubSub from 'pubsub-js'

export default function DIdi() {
  const [car, setCar] = useState("八手奥迪")
  //在组件初始化的时候 订阅一次即可
  useEffect(() => {
    PubSub.subscribe("qiche", (_, data) => {
      setCar(data)
    })
  }, []);

  return (
    <div>
      <h2>我弟弟 我开我哥的 {car}</h2>
    </div>
  )
}
